package com.learn.controller;

import com.learn.service.FormService;
import com.learn.strategy.dto.CommonPairResponse;
import com.learn.strategy.dto.FormSubmitRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @author tuzhijin
 * @version Id: SimpleController.java, v 0.1 2021/3/21 下午2:09 tuzhijin Exp $$
 */
@RestController
public class SimpleController {

    @Autowired
    private FormService formService;

    @GetMapping("/form/submit")
    public CommonPairResponse submitForm(@RequestParam String submitType,
                                         @RequestParam String formInputJson) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("key", formInputJson);
        FormSubmitRequest request = new FormSubmitRequest();
        request.setUserId(123456L);
        request.setSubmitType(submitType);
        request.setFormInput(hashMap);
        return formService.submitForm(request);
    }
}

